History for Inserting Objects and Expressions
??changed:- To render and insert a Zope object you use the caret (^) followed by the object name and optional arguments. It would look like so: <pre> ^myObj</pre> This would be the direct equivilant of <dtml-var myObj>. The insertion statement is terminated either by a line break, or a ";" if you wanted to insert HTML or other objects on the same line. To pass some arguments, it would look like this: <pre> ^myObj(arg=value, arg2=value)</pre> If you wished to render an object indirectly (specify the name of the object in a string) you would type: <pre> ^_![objName] or ^_.getitem(objName) </pre> The _ namespace object could be made implicit also leading to the possibility of calls like: <pre> ^DateTime("1/1/2001")</pre> To render the result of an expression, put the expression in parens as in: <pre> ^(foo + bar)</pre> To call a method and not render the results (ala <dtml-call>) use a bang "!" in place of the caret "^": <pre> !sql_wipe_db(key="*")</pre> In order for this to work reliably, calls statements must occupy the entire line. This should improve readability anyhow. To do formatting I propose simply using the Python formatting operator (%): <pre> ^(amount % "$%.2f")</pre> Other special formatting could be handled by string functions or even methods of a resulting string like: <pre> ^str(name).capitalize()</pre> or perhaps <pre> ^string.capitalize(name)</pre> To handle missing/null values, a function could also be used. <pre> ^missing(optionalVar, "None") ^null(paymentDate, "No Payment Yet") </pre>